#include "common.h"

void selectionSort(int array[], int n);

void main()
{
    int array[] = {6, 5, 4, 3, 2, 1};
    int len = 6;
    selectionSort(array, len);
    print(array, len);
}

void selectionSort(int array[], int n)
{
    for (int i = 0; i < n - 1; i++)
    {
        int min = i;
        for (int j = i + 1; j < n; j++)
        {
            if (array[j] < array[min])
            {
                min = j;
            }
        }
        if (i != min)
        {
            int temp = array[min];
            array[min] = array[i];
            array[i] = temp;
        }
    }
}